找传奇、传世资源到传世资源站!

Delphi10 移动开发实例

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】
Delphi10 开发手机程式
【相关图片】

【源码结构】 

unit u_Login;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  uFrame_Edit, FMX.Controls.Presentation, FMX.Edit, FMX.Objects, FMX.Layouts,
  xSuperObject;

type
  TFrm_Login = class(TFrame_Edit)
    rctngl_Top: TRectangle;
    Layout3: TLayout;
    Image1: TImage;
    Rectangle2: TRectangle;
    Layout5: TLayout;
    Layout4: TLayout;
    edt_User: TEdit;
    Img_User: TImage;
    edt_PWD: TEdit;
    Img_PWD: TImage;
    Layout6: TLayout;
    chk_Save: TCheckBox;
    Layout7: TLayout;
    btn_Login: TButton;
    edt_Code: TEdit;
    Image2: TImage;
    btn_Demo: TButton;
    Layout1: TLayout;
    Layout2: TLayout;
    Button2: TButton;
    Button3: TButton;
    procedure btn_LoginClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btn_OPClick(Sender: TObject);
  private
    { Private declarations }
    sFile:string;

    Procedure CF_Init;
  public
    { Public declarations }
  end;

var
  Frm_Login: TFrm_Login;

implementation
   uses u_DM,xFunc,EncdDecd,u_DMUse;
{$R *.fmx}

{ TFrame_Edit2 }
 
procedure TFrm_Login.btn_LoginClick(Sender: TObject);
Var Info:ISuperObject;
begin
  inherited;
  Try
    Info:=SO('{}');
    Info.S['Code']:=edt_Code.Text;
    Info.S['User']:=edt_User.Text;
    V_SvrIP:=edt_Code.Text;
    if (chk_Save.IsChecked) and (edt_PWD.Text<>'') then begin
      Info.S['pw']:=EncodeString(edt_PWD.Text);

    end
    else
      Info.S['pw']:='';
    Info.B['IsKeep']:=chk_Save.IsChecked;

    if DM.System_Login(Info) then begin
      DM_Use.DB_login;

      CF_Init;

      Info.SaveTo(sFile,true);

      DM.GoForm(0);
    end;
  Except
  End;
end;

procedure TFrm_Login.btn_OPClick(Sender: TObject);
Var Info:ISuperObject;
begin
  inherited;
  Info:=SO('{}');
  Info.S['Code']:='';
  Info.S['User']:='';
  Info.S['pw']:='';
  Info.B['IsKeep']:=False;
  Info.SaveTo(sFile,true);

  edt_Code.Text:='';
  edt_User.Text:='';
  edt_PWD.Text:='';
  chk_Save.IsChecked:=False;

  V_LoginState:=0;
  btn_Login.Enabled:= V_LoginState=0;
  btn_OP.Visible:= Not btn_Login.Enabled;
  btn_Demo.Visible:= btn_Login.Enabled;
  chk_Save.Enabled:= btn_Login.Enabled;
  edt_Code.Enabled:=btn_Login.Enabled;
  edt_User.Enabled:=btn_Login.Enabled;
  edt_PWd.Enabled:=btn_Login.Enabled;
end;

procedure TFrm_Login.CF_Init;
begin

end;

procedure TFrm_Login.FormCreate(Sender: TObject);
Var Info:ISuperObject;
begin
  inherited;
  sFile:=V_Path 'Config.Json';
  Info:=SO('{}');
  if(FileExists(sFile)) then begin
    Info:=SO(FileGetContents(sFile));
    edt_Code.Text:=Info.S['Code'];
    edt_User.Text:=Info.S['User'];
    if Info.S['pw']<>'' then
      edt_PWD.Text:=DecodeString(Info.S['pw']);
    chk_Save.IsChecked:=Info.B['IsKeep'];
  end;

  rctngl_Top.Height:=Self.Height* 0.22;
end;

procedure TFrm_Login.FormShow(Sender: TObject);
begin
  inherited;
  btn_Login.Enabled:= V_LoginState=0;
  edt_Code.Enabled:=btn_Login.Enabled;
  edt_User.Enabled:=btn_Login.Enabled;
  edt_PWd.Enabled:=btn_Login.Enabled;
  btn_OP.Visible:= Not btn_Login.Enabled;
  btn_Demo.Visible:= btn_Login.Enabled;
  chk_Save.Enabled:= btn_Login.Enabled;
end;

end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复